package com.bckj.fastboot.core.web.configuration;

import com.bckj.fastboot.core.web.repeat.RepeatSubmitInterceptor;
import com.bckj.fastboot.core.web.repeat.strategy.RepeatSubmitProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@AutoConfiguration
public class FastWebConfiguration implements WebMvcConfigurer {

    @Bean
    public RepeatSubmitProvider repeatSubmitProvider() {
        return new RepeatSubmitProvider();
    }

    @Bean
    public RepeatSubmitInterceptor repeatSubmitInterceptor() {
        return new RepeatSubmitInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(repeatSubmitInterceptor());
    }
}
